package com.py.custom.business.demo.feign.enums;

import com.py.custom.common.web.exception.BizException;

/**
 * description：渠道数据
 */
public enum ChannelType {

    /**
     * 钉钉渠道
     */
    DING_DING(1, "钉钉", "com.py.custom.business.demo.feign.adapter.DingDingChannelAdapter"),

    /**
     * 微信渠道
     */
    WEI_XIN(2, "微信", "com.py.custom.business.demo.feign.adapter.WeiXinChannelAdapter"),

    /**
     * 短信渠道
     */
    SMS(3, "短信", "com.py.custom.business.demo.feign.adapter.WeiXinChannelAdapter"),
    ;

    ChannelType(Integer channelId, String name, String clazz) {
        this.channelId = channelId;
        this.name = name;
        this.clazz = clazz;
    }

    Integer channelId;

    String name;

    String clazz;

    /**
     * 通过渠道主键，获取适配类
     *
     * @param channelId
     * @return
     */
    public static String getClazz(Integer channelId) {
        for (ChannelType channel : values()) {
            if (channel.channelId.intValue() == channelId) {
                return channel.clazz;
            }
        }
        throw new BizException("没有找到对应的渠道");
    }
}
